/*
 * Created by JFormDesigner on Tue Jun 18 21:36:30 CST 2024
 */

package 作业;

import javax.swing.*;
import javax.swing.GroupLayout;
import java.awt.event.ActionEvent;
import java.sql.SQLException;

/**
 * @author RYTHON
 */
public class AdSubEd extends JFrame {
    public AdSubEd(String start,String end,String cost,String time,String num,String id) {

        initComponents(start, end, cost, time, num, id);
    }

    private void initComponents(String start,String end,String cost,String time,String num,String id) {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents  @formatter:off
        label1 = new JLabel();
        label2 = new JLabel();
        label3 = new JLabel();
        label4 = new JLabel();
        label5 = new JLabel();
        label6 = new JLabel();
        textField1 = new JTextField();
        textField1.setText(start);
        textField2 = new JTextField();
        textField2.setText(end);
        textField3 = new JTextField();
        textField3.setText(cost);
        textField4 = new JTextField();
        textField4.setText(time);
        textField6 = new JTextField();
        textField6.setText(id);
        textField6.setEnabled(false);
        button1 = new JButton();
        spinner1 = new JSpinner(new SpinnerNumberModel(Integer.valueOf(num).intValue(),0,1000,1));

        button1.setAction(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try{
                    Getdb.op.Ed_T(textField1.getText(),textField2.getText(),textField3.getText(),textField4.getText(),(Integer) spinner1.getValue(),textField6.getText());
                    JOptionPane.showMessageDialog(null, "修改成功","提示",JOptionPane.WARNING_MESSAGE);
                    dispose();
                    new AdEditTicket().setVisible(true);
                } catch (SQLException ex) {
                    JOptionPane.showMessageDialog(null , "修改失败","提示",JOptionPane.YES_OPTION);
                }
            }
        });
        //======== this ========
        var contentPane = getContentPane();

        //---- label1 ----
        label1.setText("\u59cb\u53d1");

        //---- label2 ----
        label2.setText("\u7ec8\u70b9");

        //---- label3 ----
        label3.setText("\u8d39\u7528");

        //---- label4 ----
        label4.setText("\u65f6\u95f4");

        //---- label5 ----
        label5.setText("\u4f59\u7968");

        //---- label6 ----
        label6.setText("\u7f16\u53f7");

        //---- button1 ----
        button1.setText("\u786e\u5b9a");

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(40, 40, 40)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addComponent(label1, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
                        .addComponent(label2)
                        .addComponent(label3)
                        .addComponent(label4)
                        .addComponent(label5)
                        .addComponent(label6))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                            .addComponent(textField1, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                            .addComponent(textField2, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                            .addComponent(textField3, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                            .addComponent(textField4, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE)
                            .addComponent(textField6, GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE))
                        .addComponent(button1, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
                        .addComponent(spinner1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(91, Short.MAX_VALUE))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addGap(22, 22, 22)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label1)
                        .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label2)
                        .addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label3)
                        .addComponent(textField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(contentPaneLayout.createParallelGroup()
                        .addComponent(label4)
                        .addComponent(textField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label5)
                        .addComponent(spinner1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(contentPaneLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(label6)
                        .addComponent(textField6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                    .addComponent(button1, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents  @formatter:on
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables  @formatter:off
    private JLabel label1;
    private JLabel label2;
    private JLabel label3;
    private JLabel label4;
    private JLabel label5;
    private JLabel label6;
    private JTextField textField1;
    private JTextField textField2;
    private JTextField textField3;
    private JTextField textField4;
    private JTextField textField6;
    private JButton button1;
    private JSpinner spinner1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables  @formatter:on
}
